package com.tbit.mvc.handler;

import com.tbit.uqbike.webmanager.controller.interceptor.HttpHeadName;
import com.tbit.uqbike.webmanager.controller.interceptor.LanguageInterceptor;
import org.springframework.web.servlet.LocaleResolver;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Locale;

/**
 * created by Kang on 2019/3/29 10:44
 * description:自定义请求头国际化处理
 */
public class MyAcceptHeaderLocaleResolver implements LocaleResolver {
    @Override
    public Locale resolveLocale(HttpServletRequest request) {
        return LanguageInterceptor.parseLocaleValue(request.getHeader(HttpHeadName.REQUEST_ATTR_NAME_LANG));
    }


    @Override
    public void setLocale(HttpServletRequest request, HttpServletResponse response, Locale locale) {
    }
}
